Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

547
Vistas
HTML5 Audio Throwing Error on iOS Safari only: "Unhandled Promise Rejection: NotSupportedError: The operation is not supported."

I'm trying to play/pause an mp3 HTML5 audio on clicking button (having id "playaudio"), it is working fine on all devices except on iOS Safari, it is showing the following error on Safari in the console when clicking on play button:

Unhandled Promise Rejection: NotSupportedError: The operation is not supported."

Can anyone tell me why I'm facing this issue only on Safari, and how can I fix it?

let song = document.getElementById("testingsong");

$('#playaudio').click(function() {
  var clicks = $(this).data('clicks');
  if (clicks) {
    $(".play").css("display", "none");
    $(".pause").css("display", "block");
    song.play();
  } else {
    $(".play").css("display", "block");
    $(".pause").css("display", "none");
    song.pause();
  }
  
  $(this).data("clicks", !clicks);
});
<audio id="testingsong" src="/audio.mp3"></audio>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda